import {$post} from './request'

export const $login = async (params)=>{
        //
        let data = await $post('/User/login', params)
        
        console.log(data,"loginapi")
        if(data.code==1){
            localStorage.setItem('userID', params.userId);
            localStorage.setItem('token', data.data.token);
            const storedUserID = localStorage.getItem('token');
            console.log(storedUserID,"loginapi")
        }else{
           console.log(1111111)
        }
        
        
       // console.log('User ID:', storedUserID);
        return data;
        return {code, msg , mineMenus}
    
        if(success){
            /*let {token} = data;
            // 将token信息保存到浏览器缓存中
            sessionStorage.setItem('token',token)
            // 在请求头中更新token信息
            $setToken(token)*/
            sessionStorage.setItem('mineMenus',JSON.stringify(mineMenus))
            message.success(msg)
        }else{
            message.error(msg)
        }
        //
        return {code, msg}
    }


    export const $register = async (params)=>{
        //
        let data = await $post('/User/Webregister', params)
        console.log(data,"Register")
        return data;
    
    }
    